<template>
  <div class="my">
    <div class="myBac">
      <img class="bg" src="../../public/imgs/mybgnew.jpg" alt="" />
      <div class="head">
        <div class="person" v-show="!this.$store.state.loginFlag">
          <img src="../../public/imgs/person.png" alt="" />
        </div>
        <div class="person2" v-show="this.$store.state.loginFlag">
          <img src="../../public/imgs/person2.png" alt="" />
        </div>
        <router-link to="login" v-show="!this.$store.state.loginFlag">登录/注册</router-link>
        <div v-show="this.$store.state.loginFlag" class="personLeft">第一游客</div>
      </div>
    </div>
    <!-- 钱包 -->
    <div class="money">
      <span class="iconfont pic icon-qianbao"></span>
      <span class="text">我的钱包</span>
    </div>
    <div class="balance">
      <div>
        <div>{{money}}<span style="font-size:12px">元</span></div>
        <div class="bDown">账户余额</div>
      </div>
      <div>
        <div>0</div>
        <div class="bDown">优惠劵</div>
      </div>
      <div>
        <div>0 <span class="numLeft">张</span></div>
        <div class="bDown">银行卡</div>
      </div>
    </div>
    <div class="gray"></div>
    <div class="mys" v-for="(item, index) in mys" :key="index">
      <div @click="jumpf(index)">
        <span
          class="iconfont pic color"
          :class="item.icon"
          :style="item.color"
        ></span>
        <span class="text">{{ item.text }}</span>
        <span class="fLeft iconfont icon-youjiantou1"></span>
      </div>
    </div>
    <div class="grayLit"></div>
    <div @click="jump(i)" class="mys" v-for="(item, i) in mys2" :key="i + 100">
      <span
        class="iconfont pic color"
        :class="item.icon"
        style="background: #90a4ae"
      ></span>
      <span class="text">{{ item.text }}</span>
      <span class="fLeft iconfont icon-youjiantou1"></span>
    </div>
    <footer-btn></footer-btn>
  </div>
</template>

<style lang = "less">
.my {
  background: rgb(240, 242, 245);
  height: 100vh;
   .personLeft{
         position: absolute;
          top: 8px;
          left: 120px;
          font-size: 18px;
      }
  a{
    color: white;
    &:active{
      color: white;
    }
  }
  .gray {
    display: block;
    height: 10px;
  }
  .grayLit {
    display: block;
    height: 16px;
  }
  .fLeft {
    float: right;
  }
  .myBac {
    position: relative;
    .bg {
      width: 100%;
      height: 440px;
      margin-top: -280px;
    }
    .head {
      position: absolute;
      top: 50px;
      left: 0;
      right: 0;
      color: white;
      font-size: 14px;
      .person {
        background: rgba(255, 255, 255, 0.5);
        width: 60px;
        height: 60px;
        padding: 2px;
        padding-left: 2.5px;
        border-radius: 50%;
        margin: auto;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .person2 {
        background: rgba(255, 255, 255, 0.5);
        width: 80px;
        height: 80px;
        padding: 2px;
        padding-left: 2.5px;
        border-radius: 50%;
        margin: auto;
        position: absolute;
        top: 0px;
        left: 20px;
        img {
          width: 100%;
          height: 100%;
        }
      }
     
    }
  }
  .money {
    margin: 4px 0;
    background: white;
    text-align: left;
    padding: 10px;
    .pic {
      background: #ff7043;
      color: white;
      border-radius: 30%;
      padding: 2px;
    }
    .text {
      font-size: 16px;
      padding-left: 10px;
      color: #4d4d4d;
    }
  }
  .balance {
    font-size: 20px;
    margin-top: -3px;
    padding: 10px;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    div {
      width: 100%;
    }
    .bDown {
      margin-top: 10px;
      font-size: 12px;
      color: #888;
    }
    .numLeft {
      font-size: 12px;
      color: #4d4d4d;
    }
  }
  .mys {
    margin: 4px 0;
    margin-top: -3px;
    background: white;
    text-align: left;
    padding: 10px;
    .pic {
      background: #ffa21f;
      color: white;
      border-radius: 30%;
      padding: 2px;
    }
    .text {
      font-size: 16px;
      padding-left: 10px;
      color: #4d4d4d;
    }
  }
}
</style>

<script>
import footerBtn from "../components/footerBtn.vue";
export default {
  data() {
    return {
      money: "0.00",
      mys: [
        {
          icon: "icon-dingdan",
          text: "我的订单",
          color: "background: #4fc3f7",
          rou: "order",
        },
        {
          icon: "icon-tuikuan",
          text: "我的退款",
          color: "background: #ffa21f",
          rou: "nofound",
        },
        {
          icon: "icon-fapiao",
          text: "我的发票",
          color: "background: #ffad3b",
          rou: "nofound",
        },
        {
          icon: "icon-gonglve1",
          text: "我的攻略",
          color: "background: #ffa21f",
          rou: "nofound",
        },
      ],
      mys2: [
        {
          id: 0,
          icon: "icon-yijian",
          text: "意见反馈",
          rou: "nofound",
        },
        {
          id: 1,
          icon: "icon-guanyu",
          text: "关于我们",
          rou: "nofound",
        },
      ],
    };
  },

  methods: {
    jump(index) {
      let mys = this.mys2[index].text;
      console.log(mys);
      if (index == 1) {
        this.$router.push({
          name: `aboutMe`,
          params: {
            message: mys,
          },
        });
      } else {
        this.$router.push({
          name: `nofound`,
          params: {
            message: mys,
          },
        });
      }
    },
    jumpf(index) {
      if (index == 0) {
        this.$router.push({
          name: `order`,
        });
      } else {
        let mysf = this.mys[index].text;
        this.$router.push({
          name: `nofound`,
          params: {
            message: mysf,
          },
        });
      }
    },
  },
  created(){
    if(this.$store.state.loginFlag){
      this.money = this.$store.state.money;
    }
  },
  components: {
    footerBtn,
  },
};
</script>

